﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;

namespace CHPM.SL.TheService.Code
{
    public class DefaultServiceHost : ServiceHost
    {
        private readonly IServiceBehavior[] _serviceBehaviors;

        public DefaultServiceHost(Type serviceType, Uri[] baseAddresses, IServiceBehavior[] serviceBehaviors)
            : base(serviceType, baseAddresses)
        {
            this._serviceBehaviors = serviceBehaviors;
        }

        public DefaultServiceHost(string service, Uri[] baseAddresses, IServiceBehavior[] serviceBehaviors)
            : base(service, baseAddresses)
        {
            this._serviceBehaviors = serviceBehaviors;
        }

        protected override void OnOpening()
        {
            base.OnOpening();
            foreach(var behavior in this._serviceBehaviors)
            {
                this.Description.Behaviors.Add(behavior);
            }
        }

    }
}
